﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace D2xstudio.Net
{
    public class Utilty
    {
        public static HttpWebRequest CreateHttpWebRequest(string address)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
            request.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)";
            request.Accept = @"text/html,image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, q=0.9,*/*;q=0.8";
            request.Headers[HttpRequestHeader.AcceptCharset] = @"ISO-8859-1,utf-8;q=0.7,*;q=0.7";
            request.Headers[HttpRequestHeader.AcceptEncoding] = @"gzip,deflate";
            request.Headers[HttpRequestHeader.AcceptLanguage] = @"en-us,en;q=0.5";
            request.KeepAlive = true;

            return request;
        }

        public static HttpWebRequest CreateHttpWebRequest(string address, WebRequestMethod method)
        {
            HttpWebRequest request = CreateHttpWebRequest(address);
            if (method == WebRequestMethod.POST)
            {
                request.Method = "POST";
                request.ContentType = @"application/x-www-form-urlencoded";
            }
            
            return request;
        }
    }

    public enum WebRequestMethod
    {
        POST,
        GET
    }
}
